<?php
declare (strict_types=1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class Articles extends Model
{
    //
    public function user()
    {
        return $this->hasOne(Users::class, 'id', 'user_id');
    }

    public function getTypeTextAttr($value, $data): string
    {
        $type = [
            1 => '文章',
            2 => '公告',
            3 => '通知',
            4 => '公告',
            5 => '通知',
            6 => '公告',
            7 => '通知',
            8 => '公告',
            9 => '通知',
            10 => '公告',
        ];
        return $type[$data['type']];
    }
}
